package com.earl.carnet.plugin.database;

import static org.slf4j.LoggerFactory.getLogger;

import java.util.Timer;
import java.util.TimerTask;

import org.slf4j.Logger;

import com.earl.carnet.plugin.database.config.DefaultConfig;

/**
 * 获取数据库元素据
 * 
 * @author Administrator
 *
 */
public class DataBaseMetaData { //单例，得到元数据

	private static Logger logger = getLogger(DataBaseMetaData.class);

	public static void main(String[] args) {
		try {
			DataBaseBackUpPlugin dataBasePlugin= new DataBaseBackUpPlugin();
//			dataBasePlugin.start();
			
			DefaultConfig config = dataBasePlugin.initConfig();

			if(config.getTimerPeriod() != 0){
				Timer timer = new Timer();  
				
				timer.scheduleAtFixedRate(new TimerTask() {
					
					@Override
					public void run() {
						try {
							dataBasePlugin.start();
						} catch (Exception e) {
							e.printStackTrace();
							this.cancel();
						}
					}
				}, 0, 2000); // 延迟时间，定时时间
			}
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
